<?php
class View_Pages{
	/**
	 * вывод страницы в форме редактирования/создания
	 *
	 */
	public static function showPagesEditForm($arrPage){	
		if ($arrPage['ID_page'] == 3) $hideFields = true;
		else $hideFields = false;
			
		echo '<form method="post" action="">';
			echo '<div class="box_trext_form" ' . ($hideFields ? 'style="display: none"' : '') . '>
							<label>Заголовок</label>
							<div class="info_label">
								<input type="text" value="' . (isset($arrPage['title']) ? $arrPage['title'] : '') . '" name="title" class="tx" />
							</div>
						</div>';
			
			echo '<div class="box_trext_form" ' . ($hideFields ? 'style="display: none"' : '') . '>
							<label>Имя меню</label>
							<div class="info_label">
								<input type="text" value="' . (isset($arrPage['menu_name']) ? $arrPage['menu_name'] : '') . '" name="menu_name" class="tx" />
							</div>
						</div>';
			
			echo '<div class="box_trext_form" ' . ($hideFields ? 'style="display: none"' : '') . '>
							<label>URL (адрес)</label>
							<div class="info_label">
								<input type="text" value="' . (isset($arrPage['url']) ? $arrPage['url'] : '') . '" name="url" class="tx" />
							</div>
						</div>';
			
			echo '<div class="box_trext_form">
							<label>Главный текст</label>
							<div class="info_label">
								<textarea name="text" id="wysiwyg" rows="5" style="height: 300px;">' . (isset($arrPage['text']) ? $arrPage['text'] : '') . '</textarea>
							</div>
						</div>';
			
			echo '<input type="hidden" name="ID_page" value="' . (isset($arrPage['ID_page']) ? $arrPage['ID_page'] : '') . '"  />';
			echo '<input type="image" class="mainOtpravit" value="Сохранить" src="' . W_IMAGES . 'main_otpravit.gif" />';
			
		echo '</form>';
	}
	
	/**
	 * вывод меню
	 */
	public static function showMenu($arrMenu, $reqest){
		$objSession = User_Session::instance();
				echo '<ul id="sortable">';
					foreach ($arrMenu as $arrMenu)
						echo '<li  id="sort_' . $arrMenu['ID_page'] . '"><a ' . ($reqest == $arrMenu['url'] ? 'class="green"' : '') . ' href="' . W_ABSPATH . $arrMenu['url'] . '">' . $arrMenu['menu_name'] . '</a></li>';
				echo '</ul>';
				
			/*echo '<li><a href="#">Услуги и цены</a></li>';
				echo '<li><a href="#" title="готовые, в строительстве, в разработке">Объекты</a></li>';
				echo '<li><a href="#">Контакты</a></li>';
				echo '<li><a href="#">Ссылки</a></li>';
				echo '<li><a href="#">Вакансии</a></li>';*/
	}
	
	/**
	 * вывод карты
	 *
	 */
	public static function showKarta($arrPages, $arrObject){
		echo '<ul id="karta">';
			foreach ($arrPages as $page){
				echo '<li><a href="' . W_ABSPATH . $page['url'] . '">' . $page['menu_name'] . '</a></li>';
				if ($page['url'] == 'news'){
					echo '<ul>';
						foreach ($arrObject as $typeNum=>$type){
							echo '<li>';
								echo View_Object::getTypeName($typeNum);
								echo '<ul>';
									foreach ($type as $object)
										echo '<li><a href="' . W_ABSPATH . 'object/' . $object['ID_object'] . '">' . $object['name'] . '</a></li>';
								echo '</ul>';	
							echo '</li>';						
						}
					echo '</ul>';
				}
			}
		echo '</ul>';
			
	}
	
}
?>